package com.ylsk.check.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ylsk.check.domain.dto.WithdrawalReportDTO;
import com.ylsk.check.domain.so.WithdrawalReportSO;
import com.ylsk.check.domain.vo.WithdrawalReportVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ylsk.common.annotation.Log;
import com.ylsk.common.core.controller.BaseController;
import com.ylsk.common.core.domain.AjaxResult;
import com.ylsk.common.enums.BusinessType;
import com.ylsk.check.domain.WithdrawalReport;
import com.ylsk.check.service.IWithdrawalReportService;
import com.ylsk.common.utils.poi.ExcelUtil;
import com.ylsk.common.core.page.TableDataInfo;

/**
 * 撤场上报Controller
 *
 * @author yangsy
 * @date 2023-12-21
 */
@RestController
@RequestMapping("/check/withdrawalReport")
public class WithdrawalReportController extends BaseController
{
    @Autowired
    private IWithdrawalReportService withdrawalReportService;

    /**
     * 查询撤场上报列表
     */
    @PreAuthorize("@ss.hasPermi('check:withdrawalReport:list')")
    @GetMapping("/list")
    public TableDataInfo list(WithdrawalReportSO withdrawalReportSO)
    {
        startPage();
        List<WithdrawalReportVO> list = withdrawalReportService.selectWithdrawalReportList(withdrawalReportSO);
        return getDataTable(list);
    }

    /**
     * 导出撤场上报列表
     */
    @PreAuthorize("@ss.hasPermi('check:withdrawalReport:export')")
    @Log(title = "撤场上报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WithdrawalReportSO withdrawalReportSO)
    {
        List<WithdrawalReportVO> list = withdrawalReportService.selectWithdrawalReportList(withdrawalReportSO);
        ExcelUtil<WithdrawalReportVO> util = new ExcelUtil<WithdrawalReportVO>(WithdrawalReportVO.class);
        util.exportExcel(response, list, "撤场上报数据");
    }

    /**
     * 获取撤场上报详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:withdrawalReport:query')")
    @GetMapping(value = "/{withdrawalReportId}")
    public AjaxResult getInfo(@PathVariable("withdrawalReportId") Long withdrawalReportId)
    {
        return success(withdrawalReportService.selectWithdrawalReportByWithdrawalReportId(withdrawalReportId));
    }

    /**
     * 新增撤场上报
     */
    @PreAuthorize("@ss.hasPermi('check:withdrawalReport:add')")
    @Log(title = "撤场上报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WithdrawalReportDTO withdrawalReportDTO)
    {
        return toAjax(withdrawalReportService.insertWithdrawalReport(withdrawalReportDTO));
    }

    /**
     * 修改撤场上报
     */
    @PreAuthorize("@ss.hasPermi('check:withdrawalReport:edit')")
    @Log(title = "撤场上报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WithdrawalReportDTO withdrawalReportDTO)
    {
        return toAjax(withdrawalReportService.updateWithdrawalReport(withdrawalReportDTO));
    }

    /**
     * 删除撤场上报
     */
    @PreAuthorize("@ss.hasPermi('check:withdrawalReport:remove')")
    @Log(title = "撤场上报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{withdrawalReportIds}")
    public AjaxResult remove(@PathVariable Long[] withdrawalReportIds)
    {
        return toAjax(withdrawalReportService.deleteWithdrawalReportByWithdrawalReportIds(withdrawalReportIds));
    }
}
